﻿<%@ Page Title="" Language="C#" MasterPageFile="~/OneColumn.Master" AutoEventWireup="true"
	CodeBehind="PhaseManagement.aspx.cs" Inherits="KCL.Management.PhaseManagement1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PageHeader" runat="server">
	<link type="text/css" href="../styles/themes/base/jquery.ui.all.css" rel="stylesheet" />
	<script type="text/javascript" src="../styles/ui/jquery.ui.core.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.position.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.dialog.js"></script>
	<script type="text/javascript" src="../styles/ui/jquery.ui.button.js"></script>
	<script type="text/javascript" src="../styles/external/jquery.bgiframe-2.1.2.js"></script>
	<script type="text/javascript">
		$(document).ready(function () {
			$("#divCreatePhase").dialog({
				autoOpen: false,
				modal: true,
				width: 350,
				height: 240,
				maxHeight: 700,
				title: 'Nhập thông tin công đoạn',
				resizable: false
			});
			$("#btnSave").button();
		});
		function SubmitNewPhase() {
			$.ajax({
				url: "PhaseManagement.ashx?",
				type: "POST",
				dataType: "script",
				data: {
					PhaseCode: $("#PhaseCode").val(),
					PhaseName: $("#PhaseName").val(),
					Price: $("#Price").val(),
					action: $("#action").val()
				}
			});
		}
		function DisplayPhase(id) {
			var currentRow = $("#link" + id).parent().parent().children();
			$("#PhaseCode").val($(currentRow[0]).html());
			$("#PhaseName").val($(currentRow[1]).html());
			$("#Price").val($(currentRow[2]).html());
			$("#action").val("edit");
			$("#divCreatePhase").dialog("open");
		}
		function RefreshPhase(id) {
			var currentRow = $("#link" + id).parent().parent().children();
			$(currentRow[0]).html($("#PhaseCode").val());
			$(currentRow[1]).html($("#PhaseName").val());
			$(currentRow[2]).html($("#Price").val());
		}
		function DisplayCreateCustomer() {
			$('#action').val('create');
			$('#divCreatePhase :input[type=text]').each(function () { $(this).val(''); });
			$('#divCreatePhase').dialog('open');
		}
	</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
	<asp:ObjectDataSource ID="dsPhase" TypeName="KCL.Code.Data.PhaseDAO" SortParameterName="sortExpression"
		SelectMethod="GetPhase" SelectCountMethod="GetTotalPhase" EnablePaging="true"
		runat="server"></asp:ObjectDataSource>
	<table>
		<tr>
			<td>
				<input type="button" id="btnCreatePhase" value="Thêm công đoạn" onclick="DisplayCreateCustomer();"/>
			</td>
		</tr>
	</table>
	<asp:GridView ID="gridPhase" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
		BackColor="Wheat" BorderColor="Firebrick" BorderStyle="Ridge" BorderWidth="1px"
		CellPadding="7" DataSourceID="dsPhase" GridLines="None" Width="100%" runat="server"
		EnableModelValidation="True">
		<HeaderStyle BackColor="Black" ForeColor="Azure" Font-Bold="true" Wrap="false" />
		<FooterStyle ForeColor="Maroon" BackColor="DarkGoldenrod" />
		<PagerStyle ForeColor="Snow" HorizontalAlign="Right" BackColor="SaddleBrown" />
		<RowStyle BackColor="Ivory" />
		<Columns>
			<asp:BoundField HeaderText="STT" DataField="id" />
			<asp:BoundField HeaderText="Tên công đoạn" DataField="name" />
			<asp:BoundField HeaderText="Giá thành" DataField="price" />
			<asp:TemplateField HeaderText="Quản lý">
				<ItemTemplate>
					<a href="javascript:DisplayPhase(<%# Eval("id")%>)" id="link<%# Eval("id")%>">
						<img src="../styles/images/edit.png" alt="Chỉnh sửa" style="border: 0; width:16px" /></a>
				</ItemTemplate>
			</asp:TemplateField>
		</Columns>
		<AlternatingRowStyle BackColor="Wheat" />
	</asp:GridView>
	<i>Đang xem trang
		<%=gridPhase.PageIndex + 1%>
		/
		<%=gridPhase.PageCount %></i>
	<div id="divCreatePhase">
		<table border="0" cellpadding="7px" cellspacing="3px">
			<tr>
				<td>
					Mã công đoạn
				</td>
				<td>
					<input type="text" id="PhaseCode" />
				</td>
			</tr>
			<tr>
				<td>
					Tên công đoạn
				</td>
				<td>
					<input type="text" id="PhaseName" />
				</td>
			</tr>
			<tr>
				<td>
					Giá thành
				</td>
				<td>
					<input type="text" id="Price" />
				</td>
			</tr>
		</table>
		<p />
		<center>
            <input type="button" id="btnSave" value="&nbsp;Lưu&nbsp;" onclick="SubmitNewPhase()" /></center>
		<input type="hidden" value="create" id="action" />
		<input type="hidden" value="-1" id="phaseId" />
	</div>
</asp:Content>
